﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Spider.Migrations
{
    public partial class Init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Movies",
                columns: table => new
                {
                    id = table.Column<Guid>(nullable: false),
                    title = table.Column<string>(nullable: true),
                    director = table.Column<string>(nullable: true),
                    main_actor = table.Column<string>(nullable: true),
                    country = table.Column<string>(nullable: true),
                    type = table.Column<string>(nullable: true),
                    imdb = table.Column<double>(nullable: false),
                    douban = table.Column<double>(nullable: false),
                    description = table.Column<string>(nullable: true),
                    relase_time = table.Column<string>(nullable: true),
                    created_at = table.Column<DateTime>(nullable: false),
                    updated_at = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Movies", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "Resources",
                columns: table => new
                {
                    id = table.Column<Guid>(nullable: false),
                    url = table.Column<string>(nullable: true),
                    movieid = table.Column<Guid>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Resources", x => x.id);
                    table.ForeignKey(
                        name: "FK_Resources_Movies_movieid",
                        column: x => x.movieid,
                        principalTable: "Movies",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Resources_movieid",
                table: "Resources",
                column: "movieid");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Resources");

            migrationBuilder.DropTable(
                name: "Movies");
        }
    }
}
